package com.rogan.rpc;

import java.util.HashMap;
import java.util.Map;

import com.rogan.rpc.client.ClientStubProxyFactory;
import com.rogan.rpc.client.net.BioNetClient;
import com.rogan.rpc.message.JSONMessageProtocol;
import com.rogan.rpc.message.MessageProtocol;
import com.rogan.rpc.server.LocalConfigServiceInfoDiscoverer;

public class Consumer {

	public static void main(String[] args) {
		ClientStubProxyFactory clientStubProxyFactory = new ClientStubProxyFactory();
		clientStubProxyFactory.setNetClient(new BioNetClient());
		clientStubProxyFactory.setSid(new LocalConfigServiceInfoDiscoverer() );
		
		Map<String, MessageProtocol> supportMessageProtocols = new HashMap<String, MessageProtocol>();
		supportMessageProtocols.put(JSONMessageProtocol.class.getSimpleName(), new JSONMessageProtocol());
		clientStubProxyFactory.setSupportMessageProtocols(supportMessageProtocols);
		
		DemoService demoService = clientStubProxyFactory.getProxy(DemoService.class);
		System.out.println("获得代理接口");
		
		String hello= demoService.sayHello("world");
		System.out.println(hello);
		String hello1= demoService.sayHello("dog");
		System.out.println(hello1);
	}
}
